package com.zygh.policeasset.controller;

import com.alibaba.fastjson.JSONObject;
import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.QrCodeAluminum;
import com.zygh.policeasset.service.QrCodeAluminumService;
import com.zygh.policeasset.service.QrCodeGeneratedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.io.FileNotFoundException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/qrCodeAluminum"})
@Api(tags = {"铝制二维码管理"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/QrCodeAluminumController.class */
public class QrCodeAluminumController {
    @Autowired
    QrCodeGeneratedService qrCodeGeneratedService;
    @Autowired
    QrCodeAluminumService qrCodeAluminumService;

    @RequestMapping(value = {"/add"}, method = {RequestMethod.POST})
    @ApiOperation("铝制二维码生成")
    public Object push(@RequestBody QrCodeAluminum qrCodeAluminum) {
        if (this.qrCodeAluminumService.add(qrCodeAluminum).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("添加失败");
    }

    @RequestMapping(value = {"/findAll"}, method = {RequestMethod.GET})
    @ApiOperation("二维码信息查询")
    public Object findAll(int pageNum, int pageSize) {
        return this.qrCodeAluminumService.selectList(pageNum, pageSize);
    }

    @RequestMapping(value = {"/delete"}, method = {RequestMethod.POST})
    @ApiOperation("二维码删除")
    public Object findAll(@RequestBody JSONObject json) {
        if (this.qrCodeAluminumService.delete(json.getInteger("id")).intValue() > 0) {
            return new CommonResult().success();
        }
        return new CommonResult().validateFailed("删除失败");
    }

    @RequestMapping(value = {"/exportQrCode"}, method = {RequestMethod.GET})
    @ApiOperation("资产二维码信息导出")
    public Object exportQrCode(@RequestParam("qrCodeAluminumId") Integer qrCodeAluminumId, HttpServletResponse response) {
        return this.qrCodeAluminumService.selectQrCode(qrCodeAluminumId, response);
    }

    @RequestMapping(value = {"/exportQrCodeImage"}, method = {RequestMethod.GET})
    @ApiOperation("资产二维码图片导出")
    public Object exportQrCodeImage(@RequestParam("qrCodeAluminumId") Integer qrCodeAluminumId) throws FileNotFoundException {
        return this.qrCodeAluminumService.exportQrCodeImage(qrCodeAluminumId);
    }

    @RequestMapping(value = {"/selectListByQrCodeAluminumId"}, method = {RequestMethod.GET})
    @ApiOperation("查询二维码详细信息")
    public Object findAllByQrCodeAluminumId(int pageNum, int pageSize, @RequestParam("qrCodeAluminumId") Integer qrCodeAluminumId) {
        return this.qrCodeAluminumService.selectListByQrCodeAluminumId(pageNum, pageSize, qrCodeAluminumId);
    }
}